﻿@model Telecom.Data.ODF

@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestAddOdf"
    };
}

<script type="text/javascript">

    function opBeginProcess_loading_window_add_odf() {
        $("#ContentwindowFunctionAddOdf").mask("Dữ liệu đang xử lý");
    }

    function completedAjaxRequestAddOdf(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {

            try {
                if ($("#typeODF_vnpt_site").val() == "odf_dau_gan") {

                    $("#ODF1_DAU_GAN").combogrid({ url:  _nameSubDomain + "/TCapquang/ListODfBySiteId?siteId=@Model.SITEID", });
                    $("#ODF1_DAU_GAN").combogrid('setValue', parseInt(returnObj.RedirectUrl));

                    $("#ODF1_cap_quang_hidden").val(parseInt(returnObj.RedirectUrl));

                }
                else {

                    $("#ODF2_DAU_XA").combogrid({ url: _nameSubDomain + "/TCapquang/ListODfBySiteId?siteId=@Model.SITEID", });
                    $("#ODF2_DAU_XA").combogrid('setValue', parseInt(returnObj.RedirectUrl));

                    $("#ODF2_cap_quang_hidden").val(parseInt(returnObj.RedirectUrl));
                }

            } catch (ex) { }

            $("#DUNGLUONG_CAP_QUANG").val($("#SO_PORT_ADD_ODF").val());

            close_window_elements('window_add_odf_vnpt_site');


        } else {

            $("#ContentwindowFunctionAddOdf").unmask();
            confirmOptionNormal(returnObj.Message);
        }

        return false;

    }

    $(document).ready(function () {

        if ($("#typeODF_vnpt_site").val() == "odf_dau_gan") {

            var StringvnptDauXa = $("#vnpt_dau_xa_cap_quan_hidden_ma_check").val().split('.');
            var stringVNPTDauGan = $("#vnpt_dau_gan_cap_quan_hidden_ma_check").val().split('.');
            $("#MAODF_ADDODFCQ").val("O." + stringVNPTDauGan[1] + "-" + StringvnptDauXa[1]);
            $("#TENODF_ADDODFCQ").val("O." + stringVNPTDauGan[1] + "-" + StringvnptDauXa[1]);
        }
        else {

            var StringvnptDauXa = $("#vnpt_dau_xa_cap_quan_hidden_ma_check").val().split('.');
            var stringVNPTDauGan = $("#vnpt_dau_gan_cap_quan_hidden_ma_check").val().split('.');
            $("#MAODF_ADDODFCQ").val("O." + StringvnptDauXa[1] + "-" + stringVNPTDauGan[1]);
            $("#TENODF_ADDODFCQ").val("O." + StringvnptDauXa[1] + "-" + stringVNPTDauGan[1]);

        }
        
        $("#SO_PORT_ADD_ODF").val($("#DUNGLUONG_CAP_QUANG").val());

        $("#LOAIPORT_ODF").combobox({

            url: _nameSubDomain + "/TCapquang/ListLoaiPort",
             valueField: "MA",
             textField: "TEN",
             onSelect: function (row) {

                 $("#LOAIPORT_ODF_hidden_id").val(row.MA);

             }

         });
         

        $("#LOAIODF_ODF").combobox({

            url: _nameSubDomain + "/TCapquang/ListLoaiODF",
             valueField: "MA",
             textField: "TEN",
             onSelect: function (row) {
                 $("#LOAIODF_ODF_hidden_id").val(row.MA);
             }

         });


     });


</script>

@using (Ajax.BeginForm("AddOdf", "TCapquang", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    @Html.HiddenFor(model => model.SITEID, new { id = "SITEID_ODF_hidden_id" })
    @Html.HiddenFor(model => model.ID, new { id = "ID_ODF_hidden_id" })
    @Html.HiddenFor(model => model.LOAIPORT, new { id = "LOAIPORT_ODF_hidden_id" })
    @Html.HiddenFor(model => model.LOAIODF, new { id = "LOAIODF_ODF_hidden_id" })
    
    <input type="hidden" value="@ViewBag.typeODF" id="typeODF_vnpt_site" name="typeODF_vnpt_site" />
    
    <div id="ContentwindowFunctionAddOdf" class="ContentwindowFunctionAddOdf">
        <table class="tableContentWindowFunction">
            <tr>
                <td>Vpt Site : 
                </td>
                <td>
                    <span>@ViewBag.NameSiteEntity.TEN</span>
                </td>
            </tr>

            <tr>
                <td>Mã : 
                </td>
                <td>
                    @Html.TextBoxFor(model => model.MA, new { id="MAODF_ADDODFCQ",  @class = "input_table_function maTable" })
                </td>
            </tr>
            <tr>
                <td>Tên : 
                </td>
                <td>
                    @Html.TextBoxFor(model => model.TEN, new { id="TENODF_ADDODFCQ", @class = "input_table_function" })
                </td>
            </tr>
            <tr>
                <td>Số Port : 
                </td>
                <td>
                    @Html.TextBoxFor(model => model.SOPORT, new { id="SO_PORT_ADD_ODF", @class = "input_table_function" })
                </td>
            </tr>
            <tr>
                <td>Loại Port : 
                </td>
                <td>
                    <input class="easyui-combobox" value="@Model.LOAIPORT" style="width:450px; height:27px" id="LOAIPORT_ODF" name="LOAIPORT_ODF">
                </td>
            </tr>
            <tr>
                <td>Loại ODF : 
                </td>
                <td>
                    <input class="easyui-combobox" value="@Model.LOAIODF" style="width:450px; height:27px" id="LOAIODF_ODF" name="LOAIODF_ODF">
                </td>
            </tr>
        </table>
        <div style="height: 30px"></div>
        <div class="footer_submit" style="margin-top: 10px; text-align: center">
            <button type="submit" onclick="return opBeginProcess_loading_window_add_odf(); ">
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Cập nhật ODf</span><span class="l-btn-icon icon-add">&nbsp;</span></span>
            </button>
            <button type="button" onclick="return close_window_elements('window_add_odf_vnpt_site');">
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Hủy bỏ</span><span class="l-btn-icon icon-remove">&nbsp;</span></span></button>
        </div>
    </div>
    

}